package ThreadBasicTest;

public class TestThread {
    public static void main(String[] args) {
        //3.创建子类对象
        MyThread myThread = new MyThread();
        MyThread2 myThread2 = new MyThread2();
        //4.调用start()方法
        myThread.run();//直接调用方法,没有调用线程
        myThread.start();//由Jvm调用run()方法
        for (int i = 0; i <5 ; i++) {
            System.out.println("Main"+i);

        }
        myThread2.run();
        for (int i = 0; i <5 ; i++) {
            System.out.println("ma"+i);
        }
    }
}
//1.继承Thread类
class MyThread extends  Thread{
    //线程的任务
    @Override
    //2.覆盖run()方法
    public void run() {
        for (int i = 0; i <5 ; i++) {
            System.out.println("Thread"+i);
        }
    }
}
class MyThread2 extends Thread{
    @Override
    public void run() {
        for (int i = 0; i <5 ; i++) {
            System.out.println("NyTread"+i);
        }
    }
}